package com.zang;

/**
 * @Author: ZVerify
 * @Description: TODO
 * @DateTime: 2022/9/30 17:19
 **/
public class 搜索查找位置 {

    public int searchInsert(int[] nums, int target) {

        int l = 0,r=nums.length-1;
        int mid = 0;
        while (l<=r){
            mid = l+(r-l)>>1;
            if (nums[mid]<target){
                l = mid+1;
            }else if (nums[mid]>target){
                r = mid-1;
            }else {
                return mid;
            }
        }
        return mid;
    }
}
